package cn.yhz.pethome.dept.service.impl;

import cn.yhz.pethome.base.util.ResultBean;
import cn.yhz.pethome.dept.Query.EmployeeQuery;
import cn.yhz.pethome.dept.domain.Employee;
import cn.yhz.pethome.dept.mapper.IEmployeeMapper;
import cn.yhz.pethome.dept.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeService implements IEmployeeService {
    @Autowired
    private IEmployeeMapper employeeMapper;

    @Override
    public ResultBean<Employee> queryAll(EmployeeQuery query) {
        ResultBean<Employee> result = new ResultBean<>();
        result.setTotal(employeeMapper.selectCountAll(query));
        result.setPageList(employeeMapper.selectAll(query));
        return result;
    }

    @Override
    public List<Employee> selectEmp() {
        return employeeMapper.selectEmp();
    }

    @Override
    public Employee selectById(Long id) {
        return employeeMapper.selectById(id);
    }


    @Override
    @Transactional
    public void insert(Employee employee) {
        employeeMapper.insert(employee);
    }

    @Override
    @Transactional
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        employeeMapper.delete(id);
    }

    @Override
    public void batchEmp(List<Long> ids) {
        employeeMapper.batchEmp(ids);
    }
}
